package icursoft.educationms.servive;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2016/12/21.
 */

public class PreferencesService {

    private static String SETTINGS_KEY = "ele_doctor";
    private static SharedPreferences sp;
    private static SharedPreferences.Editor editor;
    private static PreferencesService service;

    private String tokenShort = "TOKEN_SHORT";
    private String tokenLong = "TOKEN_LONG";
    private String userId = "USER_ID";
    private String isLogin = "IS_LOGIN";
    private String isFirst = "IS_FIRST";
    private String userPhone = "USER_PHONE";
    private String userInfo = "USER_INFO";

    public static PreferencesService getInstance(Context context) {

        sp = context.getSharedPreferences(SETTINGS_KEY, Context.MODE_PRIVATE);
        editor = sp.edit();
        if (service == null) {
            service = new PreferencesService();
        }
        return service;
    }

    public String getTokenShort() {
        return sp.getString(tokenShort, "");
    }

    public void setTokenShort(String token) {
        editor.putString(tokenShort, token);
        editor.commit();
    }

    public String getTokenLong() {
        return sp.getString(tokenLong, "");
    }

    public void setTokenLong(String token) {
        editor.putString(tokenLong, token);
        editor.commit();
    }

    public boolean getIsLogin() {
        return sp.getBoolean(isLogin, false);
    }

    public void setIsLogin(boolean login) {
        editor.putBoolean(isLogin, login);
        editor.commit();
    }

    public boolean getIsFirst() {
        return sp.getBoolean(isFirst, true);
    }

    public void setIsFirst(boolean login) {
        editor.putBoolean(isFirst, login);
        editor.commit();
    }

    public String getUserPhone() {
        return sp.getString(userPhone, "");
    }

    public void setUserPhone(String phone) {
        editor.putString(userPhone, phone);
        editor.commit();
    }

    public String getUserId() {
        return sp.getString(userId, "");
    }

    public void setUserId(String uid) {
        editor.putString(userId, uid);
        editor.commit();
    }

    public String getUserInfo() {
        return sp.getString(userInfo, "");
    }

    public void setUserInfo(String info) {
        editor.putString(userInfo, info);
        editor.commit();
    }


}
